package com.qf.mvc01.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/users")
public class CaptchaController {

    @RequestMapping("/login")
    public Map<String,String> login(String username, String password, String kapchar, HttpSession session){

        String captcha = (String) session.getAttribute("captcha");
        String captchaLower = captcha.toLowerCase();
        String kapcharLower = kapchar.toLowerCase();

        HashMap<String, String> map = new HashMap<>();

        if(captchaLower.equals(kapcharLower)){
            map.put("code","100");
            map.put("msg","登陆成功");
        }else {
            map.put("code","-100");
            map.put("msg","验证码错误");
        }
        return  map;
    }
}
